package cn.itcast.zt.java8.mapstruct;

import org.mapstruct.InheritConfiguration;
import org.mapstruct.InheritInverseConfiguration;
import org.mapstruct.MapperConfig;
import org.mapstruct.Mapping;

import java.util.List;
import java.util.stream.Stream;

/**
 * create by zhangtian105 on 2021/7/28
 */
@MapperConfig
public interface BaseMapping<SOURCE, TARGET> {

        /**
         * 映射同名属性
         */
        @Mapping(target = "createTime", dateFormat = "yyyy-MM-dd HH:mm:ss")
        TARGET sourceToTarget(SOURCE var1);

        /**
         * 反向，映射同名属性
         */
        @InheritInverseConfiguration(name = "sourceToTarget")
        SOURCE targetToSource(TARGET var1);

        /**
         * 映射同名属性，集合形式
         */
        @InheritConfiguration(name = "sourceToTarget")
        List<TARGET> sourceToTarget(List<SOURCE> var1);

        /**
         * 反向，映射同名属性，集合形式
         */
        @InheritConfiguration(name = "targetToSource")
        List<SOURCE> targetToSource(List<TARGET> var1);

        /**
         * 映射同名属性，集合流形式
         */
        List<TARGET> sourceToTarget(Stream<SOURCE> stream);

        /**
         * 反向，映射同名属性，集合流形式
         */
        List<SOURCE> targetToSource(Stream<TARGET> stream);
}
